<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require('../db_conn.php');

$recc=isset($_GET['recc'])?$_GET['recc']:"";
if($recc>0)
{
$sql="SELECT * FROM  tb_admin where id=$recc";
$at=$db->query($sql);
$adrow=$at->fetch_array(MYSQLI_BOTH);
}

$rec=isset($_GET['rec'])?$_GET['rec']:"";

if ($rec>0)
{
    $name=$_POST['name'];
    $password=$_POST['password'];
    $password_confirm=$_POST['password_confirm'];

    if($password==$password_confirm)
    {
    $sql="update tb_admin set name='$name',password='$password' where id='$rec' LIMIT 1";
    $rs=$db->query($sql);
        if ($rs==FALSE)
    {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('修改失败！');";
        echo "window.location.href='manager.php'";
        echo "</script>";
    }
    else
    {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('修改成功！');";
        echo "window.location.href='manager.php'";
        echo "</script>";  
    }
    }
 else 
     {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('修改失败！');";
        echo "window.location.href='manager.php'";
        echo "</script>";
    }
}


if($recc>0)
{
require ('addmanager_html1.php');
}
 else {
    require ('manager.php');
}
